package cn.wolfcode.luowowo.website.web.advice;

import cn.wolfcode.luowowo.exception.LogicException;
import cn.wolfcode.luowowo.util.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class CommonExceptionAdvice {

    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public AjaxResult logicExceptionHandle(LogicException e) {
        e.printStackTrace();
        return new AjaxResult(false, e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public AjaxResult CommonExceptionHandle(Exception e) {
        e.printStackTrace();
        return new AjaxResult(false, "系统繁忙, 请稍后重试~");
    }

}
